package B1;

import com.github.oxo42.stateless4j.delegates.FuncBoolean;

import java.util.Date;

public class GuardCondition {
    private boolean empty; //当前是否有水，若没水为true反之为false
    private boolean tmp_is_low; //当前水温是否小于100度，若是返回true反之返回false
    private boolean NOW; //当前是否为是非待机状态
    FuncBoolean is_low_and_is_not_empty() {
        return () -> !empty&&tmp_is_low;
    }
    FuncBoolean is_not_low_or_is_empty() {
        return () -> (empty||!tmp_is_low);
    }
    FuncBoolean isTime() { //判断当前时间是否应该进入休眠模式
        Date date = new Date();
        int now=date.getHours();
        if(now>=7&&now<=22)
            NOW=true;
        else
            NOW=false;
        return () -> NOW;
    }
    FuncBoolean isNotTime() {
        isTime();// 使用isTime函数更新NOW的布尔值
        return () -> !NOW;
    }
    FuncBoolean isTime_and_can_fire(){
        return ()->NOW&&!empty&&tmp_is_low;
    }
    void setEmpty(boolean empty) {
        this.empty = empty;
    }
    void setTmp_is_low(boolean tmp_is_low){this.tmp_is_low=tmp_is_low;}
}

